// JavaScript Document
/**
*@description : 方向控制控件
@@version : 1.0
*@author : WangTao
*@date : 2013-11-01
*/

$(function(){
	var areas = $('map area');		   

	jQuery.each(areas,function(ind,area){
				area.onclick = function(){
					//下面代码是真是的旋转图形，只实现了上下左右及135°角旋转，其它旋转算的太费劲了
					//我现在连正弦余弦都不会算，就不玩这个了……
					//////////////////////   我还是用css3新特性做吧，这个是我擅长的，哈哈！！！！！  ////////////
					/***********************************************************************************************************
					var degree = area.alt;
					var cContext = canvas.getContext('2d');
					var img = new Image();
					img.src = canvas.toDataURL();
					var cw = img.width, ch = img.height, cx = 0, cy = 0;
					switch(degree){
						case 90:
							cw = img.height;
							ch = img.width;
							cy = img.height * (-1);
							break;
						case 180:
							cx = img.width * (-1);
							cy = img.height * (-1);
							break;
						case 270:
							cw = img.height;
							ch = img.width;
							cx = img.width * (-1);
							break;
						//下面俩个是他们硬试出来的，这不是人干的事儿，不弄了……
						case 45:
							cw = img.height+20;
							ch = img.height;//+img.width/2;
							cy = img.width * (-1);;
							cx =250;
							break;
						case 135:
							cw = img.width+img.width;
							cx = img.width * (-0.6);
							cy = img.height * (-1.4);
							break;
					}
											
					canvas.setAttribute('width', cw);
					canvas.setAttribute('height', ch);
					canvas_buff.setAttribute('width', cw);
					canvas_buff.setAttribute('height', ch);
					cContext.rotate(degree * Math.PI / 180);
					
					cContext.drawImage(img, cx, cy);
					window.lastDegree = degree;
					
					***********************************************************************************************************/
					//看看，我牛掰的居然用一行代码全搞定，哈哈……
					//取画板container下所有canvas元素，添加滤镜效果，注意缓存画板也要添加！
					$("#canvasContainer > canvas").css("-webkit-transform",'rotate('+this.alt+'deg)');

				}//endclick
				
	});//end each

		   
		   
		   
});